package signRecord

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"user_srv/userclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetSignListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetSignListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSignListLogic {
	return &GetSignListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetSignListLogic) GetSignList(req *types.GetSignList) (resp *types.Response, err error) {
	in, err := l.svcCtx.UserRpc.GetSignList(l.ctx, &userclient.GetSignListRequest{ //获取签到列表
		UserId:   int64(req.UserId),
		Page:     int32(req.Page),
		PageSize: int32(req.PageSize),
	})
	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Code:    200,
		Message: "查询签到列表成功",
		Data:    in.List,
	}, nil
}
